import { defineStore } from "pinia";
interface ISetting {
    isOpen: boolean;
    tagShow: boolean;
    layout: string;
    theme: string;
    loadingCount: number;
}

const settingStore = defineStore('setting',{
    state:():ISetting => ({
            isOpen: true, //侧边栏是否展开
            tagShow: false, //标签页是否显示
            layout: "horizontal", //整体框架布局 vertical 侧边栏 horizontal 顶部top
            theme: "light", //主题 dark light
            loadingCount: 0, //正在请求的数据
    }),
    actions: {
        //更新设置
        UpdateSetting(type: string, value: any): void {
            this[type as keyof typeof settingStore] = value;
        },
        //更新加载
        updateLoading(value: number=1): void {
            this.loadingCount += value;
        },
        //重置加载
        resetLoading() {
            this.loadingCount = 0;
        }
    },
    storage: {
        enabled: true,
        storage: localStorage
    }
});

export default settingStore
